// 处理get请求的url参数  "/api/api/mock/userList?pageSize=10&currentPage=1"
export const getQueryVal = (url, name) => {
    const isFind = url.indexOf(name) !== -1
    if (isFind) {
        const queryArr = url.split('?')[1].split('&')
        for (let i = 0; i < queryArr.length; i++) {
            const result = queryArr[i].split('=')
            if (result[0] === name) {
                return result[1]
            }
        }
    }
    return null
}

// 处理get请求获取所有参数
export const getAllQuery = (url) => {
    const params = url.split('?')[1]
    const paramsObj = {}
    params.split('&').forEach((item) => {
        const [key, value] = item.split('=')
        paramsObj[key] = value
    })
    return paramsObj
}
